@extends('layouts.app')

@section('content')
        <div class="header">
            <ul class="breadcrumb">
                <li>权限管理</li>
                <li><a href="">编辑角色</a> </li>
            </ul>
        </div>
        <div class="main-content">
            <ul class="nav nav-tabs">
                <li class="active"><a href="#home" data-toggle="tab">编辑</a></li>
            </ul>

            <div class="rows" style="overflow: hidden;">
                <div class="col-md-12 col-lg-12">
                    <br>
                    <div id="myTabContent" class="tab-content">
                        <div class="tab-pane active in" id="home">
                            <form id="tab" class="form-horizontal" method="post">
                                <input type="hidden" name="_token" value="{{ csrf_token() }}">
                                <div class="form-group">
                                    <label for="input1" class="col-sm-2 col-md-2 control-label">名称</label>
                                    <div class="col-sm-4 col-md-4">
                                        <input type="text" class="form-control" name="name" id="name" placeholder="名称" value="{{$re->name}}" required>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="input2" class="col-sm-2 col-md-2 control-label">概述</label>
                                    <div class="col-sm-4 col-md-4">
                                        <input type="text" class="form-control" name="remark" id="remark" placeholder="概述" value="{{$re->remark}}">
                                    </div>
                                </div>


                                @foreach ($yiji as $k=>$v)
                                <div class="panel panel-default" style="margin:3px 0;">
                                    <p class="panel-heading" style="border: 1px solid #95b8e7;border-radius:0;-webkit-border-radius:0;-moz-border-radius:0;"><input type="checkbox" name="permissions[]" value="{{$v->id}}" class="valid" @if(in_array($v->id,$re->permission_id)) checked @endif>{{ $v->name }}</p>
                                    <div class="panel-body" style="padding: 10px;border: 1px solid #95b8e7;border-top:0;">
                                        @foreach ($erji as $ko=>$vo)
                                            @if($vo->cid==$v->id)
                                                <label class="Character"><input type="checkbox" name="permissions[]" value="{{$vo->id}}" @if(in_array($vo->id,$re->permission_id)) checked @endif>{{$vo->name}}</label>
                                            @endif
                                        @endforeach
                                        <div class="clearfix"></div>
                                    </div>
                                </div>
                                @endforeach

                                <div class="btn-toolbar list-toolbar">
                                    <button class="btn btn-primary">确定</button>
                                    <a href="javascript:history.back(-1);" class="btn btn-back">返回</a>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    <script type="text/javascript">
        $(function(){
			$('.panel.panel-default').each(function(){
			   $(this).find('.valid').on('click',function(){
                if(this.checked){
                    $(this).parents('.panel.panel-default').children('.panel-body').find('input').prop("checked", true);
                }else{
                    $(this).parents('.panel.panel-default').children('.panel-body').find('input').prop("checked", false);
                }
               })
			})
        })
    </script>
@stop